<template>
	<view class='route-tixian'>
		<view class="inner">
			<view class="tit">
				提现金额
			</view>
			<view class="cont">
				<view class="zf-info">
					<view class="tips">
						￥
					</view>
					<view class="sr">
						<up-input @change="handleChangePrice" fontSize="20px" border="none" type="digit"
							placeholder="请输入金额" v-model="price"></up-input>
					</view>

				</view>
				<view class='pricecont'>
					<view>当前钱包余额{{formatNumber(userwallet.price)}}元,</view>
					<view class='ti' @click="handleAllPrice">全部提现</view>
				</view>
			</view>
		</view>
		<view class="footer">
			<view class="btn" @click="handleTixian">
				提现
			</view>
		</view>
	</view>
</template>

<script setup>
	import formatNumber from '@/utils/formatNumber.js'
	import handleCache from "@/utils/cache.js"
	import {
		ref,

	} from 'vue'
	import {

		commonApi
	} from '@/api/index.js'
	import {
		onReady,
		onShow,
		onLoad,
	} from '@dcloudio/uni-app'
	const price = ref('')
	const userInfo = ref('')
	const userwallet = ref('')
	onShow(() => {
		userInfo.value = handleCache.get('userInfo')
		getuserwallet()
	})
	const getuserwallet = () => {
		let req = {
			uid: userInfo.value.id,
			shanghuid: userInfo.value.shanghuid
		}
		commonApi.userwallet(req).then((res) => {
			userwallet.value = res.data
		})
	}
	const handleAllPrice = () => {
		if (userInfo.value.price) {
			price.value = userInfo.value.price
		}
	}


	const handleTixian = () => {
		if (!price.value) {
			uni.showToast({
				icon: 'none',
				mask: true,
				title: '请输入金额'
			})
			return
		}
	}
</script>

<style lang="scss" scoped>
	.route-tixian {
		padding: 30rpx 24rpx;

		.inner {
			background-color: #fff;
			border-radius: 10rpx;
			padding: 24rpx;

			.tit {
				font-weight: 500;
				font-size: 30rpx;
			}

			.cont {
				margin-top: 30rpx;

				.zf-info {
					margin-top: 10rpx;
					padding: 15rpx 0;
					display: flex;
					align-items: center;
					justify-content: center;
					border-bottom: 1px solid #edf0f2;

					.tips {
						flex-shrink: 0;
						font-size: 38rpx;
					}

					.sr {
						flex: 1;
						padding-left: 10rpx;
					}
				}

				.pricecont {
					display: flex;
					align-items: center;
					padding: 20rpx 0;
					font-size: 24rpx;
					color: #999;

					.ti {
						margin-left: 15rpx;
						color: #EE382F;
					}
				}
			}
		}

		.footer {
			margin-top: 40rpx;

			.btn {
				width: 100%;
				height: 80rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background-color: #EE382F;
				color: #fff;
				border-radius: 50rpx;
			}
		}
	}
</style>